package com.axcbd.demo.repository;

import com.axcbd.demo.model.Temperature;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TemperatureRepository extends JpaRepository<Temperature,Integer> {

    @Query(value = "SELECT * FROM temperature ORDER BY created_at DESC LIMIT ?1", nativeQuery = true)
    List<Temperature> findTopNByCreatedAtDesc(int n);

}
